home *** CD-ROM | disk | FTP | other *** search
- Path: fmsu03.fm.intel.com!vdalvi
- From: vdalvi@mcd.intel.com (Vishram Dalvi)
- Newsgroups: comp.lang.c
- Subject: Generating pointer to struct from string
- Date: 26 Feb 1996 06:31:44 GMT
- Organization: intel Corp
- Distribution: world
- Message-ID: <4grk4g$hep@fmsu03.fm.intel.com>
- NNTP-Posting-Host: fmwu34
- Originator: vdalvi@fmwu34
-
- Hello,
-
- Say I have 3 structs aaa, bbb and ccc of type foo:
-
- struct foo {
- int flag;
- char name[30]
- } aaa, bbb, ccc;
-
- I assign some values to the data members of all 3 structs. Now I prompt the
- user for the name of one of these structs. I read in the user entry into a
- char array. Assume that the user entered "aaa". How can I generate a pointer
- to the struct "aaa" from the user entry?
- I do not want a switch/case table (if user entered "aaa", access members of
- "aaa", if user entered "bbb"...).
- How do I cast a string into a struct address??
- Thanks in advance,
-
- Vishram Dalvi
- (vdalvi@mcd.intel.com)
-
-